home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 26.zip / BS1 part 26 / Aztec C v5.2a disk 2.adf / reslib52.lzh / libstart.asm next >
Assembly Source File  |  1991-10-23  |  2KB  |  106 lines

  1. ; Copyright (C) 1986,1987 by Manx Software Systems, Inc.
  2. ;
  3. ;:ts=8
  4.  
  5. ;    libstart.a68 -- romtag for library
  6.  
  7.     include    'exec/types.i'
  8.     include    'exec/resident.i'
  9.     include    'exec/nodes.i'
  10.     include    'exec/libraries.i'
  11.  
  12. MYVERSION    equ    0
  13. MYPRI        equ    0
  14.  
  15.     cseg    ; romtag must be in first hunk
  16.  
  17.     public    _myname
  18.     public    _myid
  19.     public    _myInitTab
  20.  
  21.     moveq    #0,d0        ; don't let them run me
  22.     rts
  23.     public    _myRomTag
  24. _myRomTag:
  25.     dc.w    RTC_MATCHWORD
  26.     dc.l    _myRomTag
  27.     dc.l    endtag
  28.     dc.b    RTF_AUTOINIT
  29.     dc.b    MYVERSION
  30.     dc.b    NT_LIBRARY
  31.     dc.b    MYPRI
  32.     dc.l    _myname
  33.     dc.l    _myid
  34.     dc.l    _myInitTab
  35. endtag:
  36.     dc.w    0        ;to get things aligned to 4 byte boundary
  37.  
  38.  
  39. ;    For libraries:
  40. ;        library base in D0
  41. ;        segment list in A0
  42. ;        execbase in A6
  43.  
  44. ;    Initial startup routine for Aztec C.
  45.  
  46. ;    NOTE: code down to "start" must be placed at beginning of
  47. ;        all programs linked with Aztec Linker using small
  48. ;        code or small data.
  49.  
  50.  
  51.     public    .begin
  52. .begin
  53.     public    _myInit
  54. _myInit:
  55.     movem.l    d0-d7/a0-a6,-(sp)    
  56.     movem.l    d0/a0,-(sp)        ;save library parameters
  57.     bsr    _geta4            ;get A4
  58.     lea    __H1_end,a1
  59.     lea    __H2_org,a0
  60.     cmp.l    a1,a0            ;check if BSS and DATA together
  61.     bne    start            ;no, don't have to clear
  62.     move.w    #((__H2_end-__H2_org)/4)-1,d1
  63.     bmi    start            ;skip if no bss
  64.     move.l    #0,d0
  65. loop
  66.     move.l    d0,(a1)+        ;clear out memory
  67.     dbra    d1,loop
  68.  
  69. start
  70.     move.l    a6,_SysBase        ;put where we can get it
  71.  
  72.     lea    dos_name,a1        ;get name of dos library
  73.     jsr    -408(a6)        ;open the library any version
  74.     move.l    d0,_DOSBase        ;set it up
  75.     bne    3$            ;skip if okay
  76.  
  77.       move.l  #$38007,d7        ;AG_OpenLib | AO_DOSLib
  78.     jsr     -108(a6)        ;Alert
  79.     bra    4$
  80. 3$
  81.     jsr    __main            ;call the startup stuff
  82. 4$
  83.     add.w    #8,sp            ;pop args
  84.     movem.l    (sp)+,d0-d7/a0-a6
  85.     rts                ;and return
  86.  
  87. dos_name:
  88.     dc.b    'dos.library',0
  89.  
  90.     public    _geta4
  91. _geta4:
  92.     far    data
  93.     lea    __H1_org+32766,a4
  94.     rts
  95.  
  96.     public    __main,__H0_org
  97.  
  98.     dseg
  99.  
  100.     public    _SysBase,_DOSBase
  101.     public    __H1_org,__H1_end,__H2_org,__H2_end
  102.     bss    _SysBase,4
  103.     bss    _DOSBase,4
  104.  
  105.     end
  106.